package com.qriver.nacos.service.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class ServiceController {

//    @Value("${config.testValue}")
//    private String testValue;

    @GetMapping("/service")
    public String service(@RequestParam(required = false) String name) {
        if (StringUtils.isEmpty(name)) {
            return "hello, " + "default";//testValue;
        }
        return "hello, " + name;
    }

    @GetMapping("/test")
    public String test(@RequestParam(required = false) String name) {
        if (StringUtils.isEmpty(name)) {
            return "hello, " + "default";//testValue;
        }
        return "hello, " + name;
    }

    @GetMapping("/test2")
    public String test2(@RequestParam(required = false) String name) {
        if (StringUtils.isEmpty(name)) {
            return "hello, " + "default";//testValue;
        }
        return "hello, " + name;
    }
}
